/**
 * Created by chenjinzhuan on 15-1-14.
 */
'use strict';

angular.module('backofficeApp.questionManager.services', ['ngResource']).
    factory('questionManager', function ($resource) {
        return $resource('http://' + backOfficeHost + '/rest/v1.0/backoffice/admin/:action/:objId/:token',
            {
                objId: "@objId"   //@会在传入的对象中读取相应的属性，对象是从controller中传来的
            },
            {
                updateQuestion: {
                    method: 'PUT',
                    params: {
                        action: "backOfficeUpdateQuestion",
                        objId: "@objId"
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                getQuestionById: {
                    method: 'GET',
                    params: {
                        action: "getQuestionById",
                        objId: "@objId"
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                getQuestionList: {
                    method: 'GET',
                    params: {
                        action: "getQuestionList"
                    }
                },
                searchQuestion: {
                    method: 'POST',
                    params: {
                        action: "searchQuestion"
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                deleteQuestion: {
                    method: 'DELETE',
                    params: {
                        action: "deleteQuestion",
                        objId: "@objId"
                    }
                },
                changeQuestionOrder: {
                    method: 'PUT',
                    params: {
                        action: 'changeQuestionOrder'
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                getReplyList: {
                    method: 'POST',
                    params: {
                        action: 'getReplyList',
                        objId: '@objId',
                        token: '@token'
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                searchReply: {
                    method: 'POST',
                    params: {
                        action: "searchReply"
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                deleteReply: {
                    method: 'POST',
                    params: {
                        action: "deleteReply"
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                getNoReplyQuestion: {
                    method: 'GET',
                    params: {
                        action: "getNoReplyQuestionList",
                        objId: '@objId',
                        token: '@token'
                    },
                    headers: {
                        'Content-Type': 'application/json'
                    }
                },
                postReply: {
                    method: 'POST',
                    params: {
                        action: "backOfficePostReply",
                        objId: '@objId'
                    }
                }
            }
        );
    }).factory('CommunityService', function ($resource) {
        return $resource('http://' + backOfficeHost + '/rest/v1.0/communities/:action',
            {},
            {
                getAllCommunityService: {
                    method: 'GET',
                    params: {
                        action: "getAllCommunity"
                    }
                }
            }
        );
    }).factory('MasterDataService', function ($resource) {
        return $resource('http://' + backOfficeHost + '/rest/v1.0/masterData/regions/:action/:category',
            {
                date: "@category"
            },
            {
                getAllDicService: {
                    method: 'GET',
                    params: {
                        action: "getDataDictionaryByCategory"
                    }
                }
            }
        );
    }).factory('portraitService', function ($resource) {
        return $resource('http://' + backOfficeHost + '/rest/v1.0/masterData/getUserPortrait/0/123',
            {},
            {
                getPortraitService: {
                    method: 'GET',
                    params: {
                        action: "getUserPortrait"
                    }
                }
            }
        );
    });
